package cn.tedu.toa.management.util;

import cn.tedu.toa.management.sys.entity.SysUsers;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.subject.Subject;


/**
 * 工具类,用于获取当前登录用户的用户类
 */

public class UserUtils {
    public static String getCurrentUserName(){
        //后期通过shiro的api获取用户信息
        Subject subject= SecurityUtils.getSubject();
        SysUsers users= (SysUsers) subject.getPrincipal();
        if(users==null){
            throw new UnknownAccountException("登录超时,请重新登录!");
        }
        return users.getUsername();
    }



}
